﻿using JiveMessenger.Models;
using JiveMessenger.User;
using JiveMessenger.Utilities;
using JiveMessenger.ViewModels;
using JmShared;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace JiveMessenger.SampleData
{
    class SampleClient : IClient
    {
        public void AcknowledgeSendtMessageReceipt(int id)
        {

        }

        public void BroadcastEmoticons()
        {

        }
        public ConcurrentDictionary<string, ViewModelChat> ClosedConversations { get; set; }
        public void ClearConnectedClients()
        {
            ConnectedClients.Clear();
        }
        private ConcurrentDictionary<string, JmShared.UserInfo> _connectedClients;
        public System.Collections.Concurrent.ConcurrentDictionary<string, JmShared.UserInfo> ConnectedClients
        {
            get
            {
                if (_connectedClients == null)
                {
                    _connectedClients = new System.Collections.Concurrent.ConcurrentDictionary<string, JmShared.UserInfo>();
                    int i = 0;
                    string userName = "sskodje@gmail.com";
                    Dictionary<string, GroupPrivilege> groupMembers = new Dictionary<string, GroupPrivilege>();
                    groupMembers.Add(userName, GroupPrivilege.Member);
                    var chatGroups = new List<ChatGroup>();
                    chatGroups.Add(new ChatGroup(i++.ToString(), "group1",  groupMembers));
                    chatGroups.Add(new ChatGroup(i++.ToString(), "very long group name here, yes it is very long indeed!!!!!!", groupMembers));
                    chatGroups.Add(new ChatGroup(i++.ToString(), "group3",  groupMembers));
                    chatGroups.Add(new ChatGroup(i++.ToString(), "group4",  groupMembers));
                    chatGroups.Add(new ChatGroup(i++.ToString(), "group5",  groupMembers));
                    chatGroups.Add(new ChatGroup(i++.ToString(), "group6", groupMembers));
                    _connectedClients.GetOrAdd("sskodje@gmail.com#pc1234", new JmShared.UserInfo(userName, "pc1234")
                    {
                        //UserName = "sskodje@gmail.com",
                        ClientStatus = JmShared.ClientStatus.Busy,

                        ChatGroups = chatGroups,
                        ClientVersion = "1.0.0.7",
                        Color = "#000000",
                        FontFamily = "Segoe UI",
                        FontStyle = "Normal",
                        FontWeight = "Bold",
                        //ID = "pc1234",
                        NickName = "Sverre",
                        TimestampAfk = DateTimeOffset.MinValue
                    });


                }
                return _connectedClients;
            }
            set
            {

            }
        }

        public Network.NetworkConnection Connection
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public JmShared.UserInfo CurrentUserInfo
        {
            get
            {
                return ConnectedClients.FirstOrDefault().Value;
            }
            set
            {

            }
        }

        public Dictionary<string, IEmoticon> GetEmoticons(string userID, bool includeDefault, bool includeCustom, bool includeLineAndSpacer)
        {
            return new Dictionary<string, IEmoticon>();
        }

        public void InitSpotifyApi()
        {
            throw new NotImplementedException();
        }

        public bool IsAfk
        {
            get
            {
                if (StaticMethods.RandomNumber(0, 100) >= 50)
                    return true;
                else
                    return false;
            }
            set
            {

            }
        }

        public bool IsBusy
        {
            get
            {
                if (StaticMethods.RandomNumber(0, 100) >= 50)
                    return true;
                else
                    return false;
            }
            set
            {

            }
        }

        public bool IsLoggedIn
        {
            get
            {
                return true;
            }
            set
            {

            }
        }

        public string LastConnectedUserName
        {
            get
            {
                return "ole.skodje@gmail.com";
            }
            set
            {

            }
        }

        public void PlayNewMessageSound()
        {
            throw new NotImplementedException();
        }

        public void PlayNudgeSound()
        {
            throw new NotImplementedException();
        }

        public void Cleanup()
        {
            throw new NotImplementedException();
        }

        public void StartConnectTask(bool isAutoLogin)
        {
            throw new NotImplementedException();
        }

        public void StartReconnectTask()
        {
            throw new NotImplementedException();
        }

        public bool StopReconnectRetrying { get; set; }


        public JmShared.WpUserSettings UserSettings
        {
            get
            {
                return new JmShared.WpUserSettings(true);

            }
            set
            {

            }
        }

        public bool ValidateEmoticonShortcut(string str, out string error)
        {
            error = "";
            if (StaticMethods.RandomNumber(0, 100) >= 50)
                return true;
            else
            {
                error = "bullshit error";
                return false;
            }
        }

        public bool ValidateEmoticonShortcut(string str, string exludeShortcut, out string error)
        {
            error = "";
            if (StaticMethods.RandomNumber(0, 100) >= 50)
                return true;
            else
            {
                error = "bullshit error";
                return false;
            }
        }


        public bool IsUserConnecting { get; set; }


        public bool IsRetrying { get; set; }


        public int MessageID { get; set; }



        Dictionary<string, UserInfo> IClient.ContactClients
        {
            get
            {
                return new Dictionary<string, UserInfo>();
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public void OpenNewPM(string userID)
        {

        }


        public void StopReconnectTask()
        {
            throw new NotImplementedException();
        }


        public List<string> FriendUsernames
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public Task ChangeManualClientStatus(ClientStatus status)
        {
            return null;
        }


        public void DownloadApplicationUpdate(string downloadUrl)
        {
            throw new NotImplementedException();
        }


        public void SkipUpdateVersion(string version)
        {
            throw new NotImplementedException();
        }


        public System.Collections.ObjectModel.ObservableCollection<Models.JiveDefaultEmoticonModel> DefaultEmoticons
        {
            get
            {
                return new System.Collections.ObjectModel.ObservableCollection<Models.JiveDefaultEmoticonModel>();
            }
            set
            {
                throw new NotImplementedException();
            }
        }





        public void DisplayGroupMessage(ChatMessage msg)
        {
            throw new NotImplementedException();
        }

        public void DisplayPrivateMessage(ChatMessage msg)
        {
            throw new NotImplementedException();
        }


        public ViewModelChat GetOrOpenChatViewModel(ChatMessage msg)
        {
            throw new NotImplementedException();
        }
    }
}
